package com.wuhainan.beelzebub.controller.system;

import com.wuhainan.beelzebub.entity.system.Menu;
import com.wuhainan.beelzebub.service.system.MenuService;
import com.wuhainan.beelzebub.utils.PageInfo;
import com.wuhainan.beelzebub.utils.TableData;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <br>Created by 吴海南 on 2017-12-18.
 * <br>星期一 at 上午 10:11.
 */
@RestController
@RequestMapping("api")
public class MenuController {
    @Resource
    private MenuService menuService;
    @RequestMapping("menuPage")
    public TableData menuPage(PageInfo pageInfo, Menu menu){
        return menuService.findMenuPage(pageInfo,menu);
    }
    @RequestMapping("menu/{id}")
    public Menu menu(@PathVariable String id) {
        return menuService.findMenuById(id);
    }
    @RequestMapping("menuList")
    public List<Menu> menuList() {
        return menuService.findAll();
    }

    @RequestMapping("saveMenu")
    public void saveMenu(@RequestBody Menu menu) {
        menuService.saveMenu(menu);
    }

    @RequestMapping("deleteMenu")
    public void deleteMenu(@RequestBody Menu menu) {
        menuService.deleteMenu(menu);
    }
    @RequestMapping("restoreMenu")
    public void restoreMenu(@RequestBody Menu menu) {
        menuService.restoreMenu(menu);
    }

}
